import httplib
import json 
import time,sys

conn=httplib.HTTPConnection('app18894.qqgameapp.com')  

conn.request('POST',"/game/user/info.php?openid=0000000000000000000000005B168614&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&qz_ver=6&appcanvas=1&via=PY.TOPBAR.SEARCH", body="")

result=conn.getresponse()  
resultStatus=result.status
content=result.read()
res=json.loads(content)
#for i in res:
#  print i
print res["curQuests"]

#http://app18894.qzoneapp.com/game/building/upgrade2?queryId=qid4&postKey=aabbccdd&check=GkBUuoE7XV96MmB9qM,pgd2PrWiN5MZ7-1363144301937-73&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&openid=0000000000000000000000005B168614&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&onlysign=
#http://app18894.qzoneapp.com/game/building/upgrade2?queryId=qid5&postKey=aabbccdd&check=n8f2dxEiOAGUMGckcp4P.1M0Ha4s4EZd-1363144792789-55&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&openid=0000000000000000000000005B168614&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&onlysign=
#http://app18894.qzoneapp.com/game/building/upgrade2?queryId=qid6&postKey=aabbccdd&check=F959sLW9rEKo0hgB7MWq4.EM9fAWFeRG-1363152960009-189&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&openid=0000000000000000000000005B168614&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&onlysign=

uri="/game/battle/checkpoint"
#uri="/game/building/upgrade2"
randomStr = "F959sLW9rEKo0hgB7MWq4.EM9fAWFeRG"
timeStr = "%d000" % (time.time())
#timeStr = "1363164336000"
#val = '{"bid":1003}'
val = '{"strongholdId":2,"checkpointId":18,"npc_id":18,"fill":true}'
sum=0
for i in randomStr:
  sum = sum+ord(i)
for i in val:
  sum = sum+ord(i)+1
for i in timeStr:
  sum = sum+ord(i)
res = "%s-%s-%d" % (randomStr, timeStr, sum%256)
print res 
#http://app18894.qzoneapp.com/game/battle/checkpoint?queryId=qid4&postKey=aabbccdd&check=GcmiLw1lHinKLC6x,aT7JbfKjZmwPN12-1363155906407-147&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&openid=0000000000000000000000005B168614&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&onlysign=
#http://app18894.qqgameapp.com/game/building/upgrade2?checksum=F959sLW9rEKo0hgB7MWq4.EM9fAWFeRG-1363163429000-180&openid=0000000000000000000000005B168614&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&qz_ver=6&appcanvas=1&via=PY.TOPBAR.SEARCH

#conn.request('POST', "/game/building/upgrade2?openid=0000000000000000000000005B168614&check=F959sLW9rEKo0hgB7MWq4.EM9fAWFeRG-1363166350000-176&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&qz_ver=6&appcanvas=1&via=PY.TOPBAR.SEARCH", body=val)
conn.request('POST', "%s?openid=0000000000000000000000005B168614&check=%s&openkey=A76D7BCF866939B8121DDE9B5C9E9CD9&pf=pengyou&pfkey=c6c150ba2bd86315549585da7c3dbb49&qz_ver=6&appcanvas=1&via=PY.TOPBAR.SEARCH" % (uri, res), body=val)
result=conn.getresponse() 
content=result.read()
resultStatus=result.status
print resultStatus
print content
